﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using chessLogic;

namespace chessView
{
    public partial class StatisticsForm : Form
    {
        private DataBase db;
        private Statistics statistics;

        public StatisticsForm(string fen)
        {
            InitializeComponent();
            db = new DataBase();
            statistics = new Statistics(db.GetStatistics(fen));
            AddDataToView();
            this.Invalidate();
        }

        private void Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void AddDataToView()
        {
            DataGridViewRow row = new DataGridViewRow();
            DataGridViewCell cell0 = new DataGridViewTextBoxCell();
            DataGridViewCell cell1 = new DataGridViewTextBoxCell();
            DataGridViewCell cell2 = new DataGridViewTextBoxCell();
            DataGridViewCell cell3 = new DataGridViewTextBoxCell();
            DataGridViewCell cell4 = new DataGridViewTextBoxCell();
            for (int i = 0; i < statistics.GetStatistics().GetLength(0); i++)
            {
                cell0.Value = statistics.GetStatistics()[i, 0];
                cell1.Value = statistics.GetStatistics()[i, 1];
                cell2.Value = statistics.GetStatistics()[i, 2];
                cell3.Value = statistics.GetStatistics()[i, 3];
                cell4.Value = statistics.GetStatistics()[i, 4];
                row.Cells.AddRange(cell0, cell1, cell2, cell3, cell4);
                this.statisticsView.Rows.Add(row);
                cell0 = new DataGridViewTextBoxCell();
                cell1 = new DataGridViewTextBoxCell();
                cell2 = new DataGridViewTextBoxCell();
                cell3 = new DataGridViewTextBoxCell();
                cell4 = new DataGridViewTextBoxCell();
                row = new DataGridViewRow();
            }
        }
    }
}
